package com.someclip.component.skins
{
	import flash.display.Shape;

	public class Arrow extends Shape
	{
		private var _way:String;
		private var _color:uint;
		private var _len:Number=10;

		public function Arrow(way:String="", color:uint=0x555555)
		{
			_way=way;
			_color=color;
			if (_way != "")
			{
				drawArrow();
			}
		}

		public function set way(value:String):void
		{
			if (_way == value || value == "")
				return;
			_way=value;
			drawArrow();
		}

		private function drawArrow():void
		{
			this.graphics.clear();
			this.graphics.beginFill(_color, 1);
			switch (_way)
			{
				case "up":
					this.graphics.moveTo(_len / 2, 0);
					this.graphics.lineTo(0, _len / 2);
					this.graphics.lineTo(_len, _len / 2);
					this.graphics.lineTo(_len / 2, 0);
					break;
				case "down":
					this.graphics.moveTo(0, 0);
					this.graphics.lineTo(_len / 2, _len / 2);
					this.graphics.lineTo(_len, 0);
					this.graphics.lineTo(0, 0);
					break;
				case "left":
					this.graphics.moveTo(0, _len / 2);
					this.graphics.lineTo(_len / 2, _len);
					this.graphics.lineTo(_len / 2, 0);
					this.graphics.lineTo(0, _len / 2);
					break;
				case "right":
					this.graphics.moveTo(0, 0);
					this.graphics.lineTo(0, _len);
					this.graphics.lineTo(_len / 2, _len / 2);
					this.graphics.lineTo(0, 0);
					break;
			}
			this.graphics.endFill();
		}
	}
}
